let index = 0;
let graph = new joint.dia.Graph;

//声明画布
let paper = new joint.dia.Paper({
    el:$("#paper"),
    width:800,
    height:600,
    gridSize:10,
    drawGrid:true,
    model:graph
});

var rectangle = new joint.shapes.standard.Rectangle({id:100});
rectangle.resize(100, 100);
rectangle.position(50, 10);
rectangle.attr('root/tabindex', 1);
rectangle.attr('root/title', 'joint.shapes.standard.Rectangle');
rectangle.attr('body/fill', '#30d0c6');
rectangle.attr('body/fillOpacity', 0.5);
rectangle.attr('label/text', '点我复制');
rectangle.addTo(graph);


//画布元素点击事件
paper.on('cell:pointerdown', function(cellView, e) {
    console.log(cellView)
    copyNode();
});

function copyNode() {
    let rectangleCopy = rectangle.clone();
    rectangleCopy.addTo(graph)
}